import { Service } from "~/core/service";
import { NetService } from "~/util/net.service";
import { Inject, Debounce } from "~/core/decorator";
import { serviceManage } from "~/config/server";

export class DepartmentService extends Service {

    @Inject(NetService)
    private netService: NetService;

    /**
     * 新增机构
     * @param data 
     */
    createDept(data) {
        return this.netService.send({
            server: serviceManage.departmentController.createDept,
            data: {
                deptName: data.deptName,
                deptProperty: data.deptProperty,
                deptType: data.deptType,
                deptPid: data.deptPid,
                remark: data.remark
            }
        })
    }

    /**
     * 修改机构
     * @param data 
     */
    updateDept(data) {
        return this.netService.send({
            server: serviceManage.departmentController.updateDept,
            data: {
                deptName: data.deptName,
                remark: data.remark,
                id: data.id
            }
        })
    }

    /**
     * 
     * @param deptId 删除机构
     */
    deleteDept(deptId) {
        return this.netService.send({
            server: serviceManage.departmentController.deleteDept,
            append: deptId
        })

    }

    /**
     * 获取所有机构
     */
    getAllDeptList() {
        return this.netService.send({
            server: serviceManage.departmentController.getAllDeptList
        })
    }
}